﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DGSFramework;

namespace Framework
{
    public partial class Register : System.Web.UI.Page
    {
        DGSFrameworkEntities entity = new DGSFrameworkEntities();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                LoadCustomerEvent();
            }
        }

        protected void btnRegEvent_Click(object sender, EventArgs e)
        {
            try
            {
                udv_CustomerEvent uCusEvent = new udv_CustomerEvent();
                uCusEvent.FullName = tbFullName.Text;
                uCusEvent.Email = tbEmail.Text;
                uCusEvent.Address = tbAddress.Text;
                uCusEvent.DateAdded = DateTime.Now;
                uCusEvent.Phone = Int32.Parse(tbPhone.Text);
                entity.AddToudv_CustomerEvent(uCusEvent);
                entity.SaveChanges();
            }
            catch (Exception)
            {

                throw;
            }
        }

        public void LoadCustomerEvent()
        {
            try
            {
                var customerEvent = entity.udv_CustomerEvent.ToList();
                gvCustomerEvent.DataSource = customerEvent;
                gvCustomerEvent.DataBind();
            }
            catch (Exception)
            {

                throw;
            }
        }

        protected void btnCancelEvent_Click(object sender, EventArgs e)
        {

        }
    }
}